<html>
<head><meta charset="utf-8"><title>design meeting 2021-03-31 · t-lang · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/index.html">t-lang</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/design.20meeting.202021-03-31.html">design meeting 2021-03-31</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="232627323"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/design%20meeting%202021-03-31/near/232627323" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/design.20meeting.202021-03-31.html#232627323">(Mar 31 2021 at 17:00)</a>:</h4>
<p>Hey <span class="user-group-mention" data-user-group-id="1977">@T-lang</span> -- today's design meeting is "how to dismantle an &amp;Atomic bomb"</p>



<a name="232627385"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/design%20meeting%202021-03-31/near/232627385" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/design.20meeting.202021-03-31.html#232627385">(Mar 31 2021 at 17:00)</a>:</h4>
<p>race condition 101</p>



<a name="232627409"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/design%20meeting%202021-03-31/near/232627409" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/design.20meeting.202021-03-31.html#232627409">(Mar 31 2021 at 17:00)</a>:</h4>
<p>(I made a parallel topic with slightly different name at same time)</p>



<a name="232627459"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/design%20meeting%202021-03-31/near/232627459" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/design.20meeting.202021-03-31.html#232627459">(Mar 31 2021 at 17:01)</a>:</h4>
<p>I’m going to be a minute late, but my intention was that we would open the meeting by reading the writeup I made</p>



<a name="232627552"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/design%20meeting%202021-03-31/near/232627552" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/design.20meeting.202021-03-31.html#232627552">(Mar 31 2021 at 17:01)</a>:</h4>
<p>writeup: <a href="https://hackmd.io/p0sspE8pSSSfBuLV0EwIlw">https://hackmd.io/p0sspE8pSSSfBuLV0EwIlw</a></p>



<a name="232627717"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/design%20meeting%202021-03-31/near/232627717" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/design.20meeting.202021-03-31.html#232627717">(Mar 31 2021 at 17:02)</a>:</h4>
<p>to track who’s working on reading, add yourself to <span aria-label="book" class="emoji emoji-1f4d6" role="img" title="book">:book:</span> here when you start reading. Keep it clicked the whole time. When you’re done reading, add yourself to <span aria-label="times up" class="emoji emoji-231b" role="img" title="times up">:times_up:</span>. (And then if the two numbers are equal after 5 to 8 minutes, we’ll know we can safely start.)</p>



<a name="232627977"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/design%20meeting%202021-03-31/near/232627977" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/design.20meeting.202021-03-31.html#232627977">(Mar 31 2021 at 17:03)</a>:</h4>
<p>(also there’s relevant discussion over on a parallel zulip topic, #<strong>t-lang&gt;Whither *Atomic API duplication</strong> )</p>



<a name="232628672"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/design%20meeting%202021-03-31/near/232628672" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/design.20meeting.202021-03-31.html#232628672">(Mar 31 2021 at 17:07)</a>:</h4>
<p><span class="user-mention" data-user-id="116083">@pnkfelix</span> Are you focused primarily on immediate-deallocation strategies, or do you also want this to support deferred-reclamation strategies (e.g. RCU or hazard pointers)?</p>



<a name="232641618"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/design%20meeting%202021-03-31/near/232641618" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/design.20meeting.202021-03-31.html#232641618">(Mar 31 2021 at 18:29)</a>:</h4>
<p>trade-offs regarding the <code>dereferencable</code> attribute and various possible models: we consider the types <code>&amp;i32</code>, <code>&amp;Cell&lt;i32&gt;</code>, and <code>&amp;(i32, Cell&lt;i32&gt;)</code>.</p>
<ul>
<li>status quo: all are <code>dereferencable</code></li>
<li>mutation is freedom without bubbling: <code>&amp;i32</code> and <code>&amp;(i32, Cell&lt;i32&gt;)</code> are deref (but for the latter, the argument is subtle); <code>&amp;Cell&lt;i32&gt;</code> is not</li>
<li>mutation is freedom with bubbling, mutation is volatile freedom (with or without bubbling): <code>&amp;i32</code> is deref; <code>&amp;Cell&lt;i32&gt;</code> and <code>&amp;(i32, Cell&lt;i32&gt;)</code> are not</li>
</ul>
<p>this is the "old" LLVM <code>dereferencable</code>, i.e., "dereferencable for the entire duration of the fn call and the entire memory range it points to".<br>
by "bubbling" I mean the most aggressive version of that, where every <code>&amp;!Freeze</code> reference has <code>SharedReadWrite</code> permission for the entire range it points to -- this is the version of bubbling that actually brings tangible benefits elsewhere in the model since it means that each reference has the same permission for all the bytes it covers.</p>



<a name="232641805"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/design%20meeting%202021-03-31/near/232641805" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/design.20meeting.202021-03-31.html#232641805">(Mar 31 2021 at 18:30)</a>:</h4>
<p>I think the <em>only</em> optimization that "mutation is volatile freedom without bubbling" loses when compared with "mutation is freedom without bubbling" is when we have a live <code>&amp;(i32, Cell&lt;i32&gt;)</code> (live because "function calls are special" or because it is used again). then the latter lets us introduce spurious reads for the <code>Cell</code> part of this type, and the former (the volatile one) does not. this seems like a small sacrifice to make if in exchange we get that UnsafeCell <em>is</em> VolatileCell.</p>



<a name="232642660"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/design%20meeting%202021-03-31/near/232642660" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/design.20meeting.202021-03-31.html#232642660">(Mar 31 2021 at 18:35)</a>:</h4>
<p>formally, the volatile part basically means that when you have <code>SharedReadWrite</code> permission (and only then), it might be the case that reads to the given memory have side-effects. so <code>&amp;mut</code> remains the same and may still do spurious reads (so this is not "if you can mutate you can exclude spurious reads" -- I am saying that just in case people want to draw an analogy to "if you can mutate you can deallocate"; that analogy would not work)</p>



<a name="232643340"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/design%20meeting%202021-03-31/near/232643340" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/design.20meeting.202021-03-31.html#232643340">(Mar 31 2021 at 18:40)</a>:</h4>
<p>I want to reframe this a bit</p>



<a name="232643351"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/design%20meeting%202021-03-31/near/232643351" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/design.20meeting.202021-03-31.html#232643351">(Mar 31 2021 at 18:40)</a>:</h4>
<p>or at least</p>



<a name="232643386"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/design%20meeting%202021-03-31/near/232643386" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/design.20meeting.202021-03-31.html#232643386">(Mar 31 2021 at 18:40)</a>:</h4>
<p>I would like to see coverage of "how we would teach this", so to speak</p>



<a name="232643388"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/design%20meeting%202021-03-31/near/232643388" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/design.20meeting.202021-03-31.html#232643388">(Mar 31 2021 at 18:40)</a>:</h4>
<p>for each option</p>



<a name="232643596"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/design%20meeting%202021-03-31/near/232643596" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/design.20meeting.202021-03-31.html#232643596">(Mar 31 2021 at 18:42)</a>:</h4>
<p>Yeah that's fair, but I have given much less thought to that. ;)  This was mostly meant for whoever finalizes the meeting notes, to make sure we got the concrete technical aspects of this covered properly (as I felt there was some confusion with all the models floating around).</p>



<a name="232643746"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/design%20meeting%202021-03-31/near/232643746" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/design.20meeting.202021-03-31.html#232643746">(Mar 31 2021 at 18:43)</a>:</h4>
<p>if the three cases listed <del>at</del> are the same under “mutation is volatile freedom” both with or without bubbling, then … it would be good to spell out the case where bubbling <em>does</em> make a difference.</p>



<a name="232643993"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/design%20meeting%202021-03-31/near/232643993" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/design.20meeting.202021-03-31.html#232643993">(Mar 31 2021 at 18:45)</a>:</h4>
<p>and also, I get impression that if you start bubbling, then you run into issues where starting with <code>&amp;(A, B)</code> and turning it into <code>&amp;A</code> and <code>&amp;B</code> (and then perhaps passing those <code>&amp;A</code> and <code>&amp;B</code> to a helper), you run into big trouble potentially, right?</p>



<a name="232644172"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/design%20meeting%202021-03-31/near/232644172" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/design.20meeting.202021-03-31.html#232644172">(Mar 31 2021 at 18:46)</a>:</h4>
<p>Big trouble in the sense of “before the split, lots of code was accepted, because the bubbling would ensure compiler optimizations would not fire (and/or that someone’s unsafe code would be valid). But then the developer introduced the split, and now things that <em>look</em> like innocent refactorings, in fact are not.</p>



<a name="232644351"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/design%20meeting%202021-03-31/near/232644351" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/design.20meeting.202021-03-31.html#232644351">(Mar 31 2021 at 18:47)</a>:</h4>
<p>(But I guess the “innocent refactoring” argument is not a good place to try to establish a foundation, given that both Ralf and Niko argued quite strongly that local variables simply <em>are</em> different from function parameters, and thus no refactoring is “simple” in these scenarios.)</p>



<a name="232644609"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/design%20meeting%202021-03-31/near/232644609" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/design.20meeting.202021-03-31.html#232644609">(Mar 31 2021 at 18:49)</a>:</h4>
<p>there is definitely some confusion</p>



<a name="232644675"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/design%20meeting%202021-03-31/near/232644675" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/design.20meeting.202021-03-31.html#232644675">(Mar 31 2021 at 18:50)</a>:</h4>
<p><span class="user-mention" data-user-id="116083">@pnkfelix</span> it is true that in rust introducing functions sometimes breaks things in ways that are unfortunate, in my view (e.g., introducing borrow check failures) -- not sure how I feel about that in this case, but it is a valid point</p>



<a name="232646902"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/design%20meeting%202021-03-31/near/232646902" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/design.20meeting.202021-03-31.html#232646902">(Mar 31 2021 at 19:04)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116083">pnkfelix</span> <a href="#narrow/stream/213817-t-lang/topic/design.20meeting.202021-03-31/near/232643746">said</a>:</p>
<blockquote>
<p>if the three cases listed <del>at</del> are the same under “mutation is volatile freedom” both with or without bubbling, then … it would be good to spell out the case where bubbling <em>does</em> make a difference.</p>
</blockquote>
<p>yeah fair... I don't have time to write that out now though. :/ I'll take a note to get back to you on this over the Easter weekend.</p>



<a name="232806230"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/design%20meeting%202021-03-31/near/232806230" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/design.20meeting.202021-03-31.html#232806230">(Apr 01 2021 at 18:50)</a>:</h4>
<p><span class="user-mention" data-user-id="116083">@pnkfelix</span> can you transfer ownership of your doc to <code>rust-lang-team</code> ?</p>



<a name="232806400"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/design%20meeting%202021-03-31/near/232806400" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/design.20meeting.202021-03-31.html#232806400">(Apr 01 2021 at 18:51)</a>:</h4>
<p>or..maybe it already is</p>



<a name="232997549"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/design%20meeting%202021-03-31/near/232997549" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/design.20meeting.202021-03-31.html#232997549">(Apr 03 2021 at 10:39)</a>:</h4>
<p><span class="user-mention silent" data-user-id="120791">RalfJ</span> <a href="#narrow/stream/213817-t-lang/topic/design.20meeting.202021-03-31/near/232641805">said</a>:</p>
<blockquote>
<p>I think the <em>only</em> optimization that "mutation is volatile freedom without bubbling" loses when compared with "mutation is freedom without bubbling" is when we have a live <code>&amp;(i32, Cell&lt;i32&gt;)</code> (live because "function calls are special" or because it is used again). then the latter lets us introduce spurious reads for the <code>Cell</code> part of this type, and the former (the volatile one) does not. this seems like a small sacrifice to make if in exchange we get that UnsafeCell <em>is</em> VolatileCell.</p>
</blockquote>
<p>actually I think introducing spurious reads is okay even under the volatile variant... "compatibility with volatile" just requires "no spurious reads <em>unless there was at least one non-volatile read</em>. So when the <code>Cell</code> part is actually read in a regular way (<code>x.1.get()</code>), then we can insert spurious reads even with the volatile variant.</p>



<a name="232997725"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/design%20meeting%202021-03-31/near/232997725" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/design.20meeting.202021-03-31.html#232997725">(Apr 03 2021 at 10:43)</a>:</h4>
<p><span class="user-mention" data-user-id="116083">@pnkfelix</span> here's an example distinguishing volatile from the non-volatile variants (bubbling or not makes no difference for this example):</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">fn</span> <span class="nf">foo</span><span class="p">(</span><span class="n">x</span>: <span class="kp">&amp;</span><span class="p">(</span><span class="kt">i32</span><span class="p">,</span><span class="w"> </span><span class="n">Cell</span><span class="o">&lt;</span><span class="kt">i32</span><span class="o">&gt;</span><span class="p">,</span><span class="w"> </span><span class="kt">i32</span><span class="p">))</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">  </span><span class="kd">let</span><span class="w"> </span><span class="n">_val</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">x</span><span class="p">.</span><span class="mi">0</span><span class="p">;</span><span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="n">_val</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">x</span><span class="p">.</span><span class="mi">2</span><span class="p">;</span><span class="w"></span>
<span class="w">  </span><span class="c1">// can the compiler do a spurious read of x.1?</span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>
<p>Under the volatile semantics the compiler most certainly cannot do a spurious read of x.1, as that region wasn't read so we have to assume reads are side-effecting.<br>
If we dont account for volatile, I think one can make the argument that since both x.0 and x.2 are clearly in-bounds of the same allocation, so is x.1, and hence we can perform spurious reads. This argument would work even if <code>x</code> were a raw pointer. I have no idea if LLVM does things like this.</p>



<a name="232997802"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/design%20meeting%202021-03-31/near/232997802" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/design.20meeting.202021-03-31.html#232997802">(Apr 03 2021 at 10:45)</a>:</h4>
<p>Cc <span class="user-mention" data-user-id="224471">@Lokathor</span> for the last point -- do you know anything about situations where disjoint parts of a single allocation are used with volatile and non-volatile accesses, respectively? Does LLVM use the non-volatile accesses to deduce information about the volatile parts?</p>



<a name="233005013"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/design%20meeting%202021-03-31/near/233005013" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/design.20meeting.202021-03-31.html#233005013">(Apr 03 2021 at 13:02)</a>:</h4>
<p>not to my knowledge</p>



<a name="233005059"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/design%20meeting%202021-03-31/near/233005059" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/design.20meeting.202021-03-31.html#233005059">(Apr 03 2021 at 13:03)</a>:</h4>
<p>but I'll mention that a spurious read that's before when the read was supposed to happen can be a problem</p>



<a name="233005107"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/design%20meeting%202021-03-31/near/233005107" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/design.20meeting.202021-03-31.html#233005107">(Apr 03 2021 at 13:04)</a>:</h4>
<p>you mean even for non-volatile accesses?</p>



<a name="233006431"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/design%20meeting%202021-03-31/near/233006431" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/design.20meeting.202021-03-31.html#233006431">(Apr 03 2021 at 13:27)</a>:</h4>
<p>uh, early standard reads should be fine</p>



<a name="233006508"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/design%20meeting%202021-03-31/near/233006508" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/design.20meeting.202021-03-31.html#233006508">(Apr 03 2021 at 13:28)</a>:</h4>
<p>i thought you meant an early standard read instead of the volatile read that was intended</p>



<a name="233008721"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/design%20meeting%202021-03-31/near/233008721" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/design.20meeting.202021-03-31.html#233008721">(Apr 03 2021 at 14:03)</a>:</h4>
<p>Yeah, okay, i keep re-reading it to try and be sure. If there's only spurious non-volatile reads allowed when there's also at least one non-volatile read in the source, it should be fine.</p>



<a name="233010035"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/design%20meeting%202021-03-31/near/233010035" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/design.20meeting.202021-03-31.html#233010035">(Apr 03 2021 at 14:28)</a>:</h4>
<p><span class="user-mention silent" data-user-id="224471">Lokathor</span> <a href="#narrow/stream/213817-t-lang/topic/design.20meeting.202021-03-31/near/233008721">said</a>:</p>
<blockquote>
<p>Yeah, okay, i keep re-reading it to try and be sure. If there's only spurious non-volatile reads allowed when there's also at least one non-volatile read in the source, it should be fine.</p>
</blockquote>
<p>that was my thinking, yes<br>
("spurious volatile reads" are not a thing; spurious reads are always non-volatile)</p>



<a name="233954310"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/design%20meeting%202021-03-31/near/233954310" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/design.20meeting.202021-03-31.html#233954310">(Apr 10 2021 at 13:13)</a>:</h4>
<p><span class="user-mention" data-user-id="116083">@pnkfelix</span> regarding the example that distinguishes volatile from non-volatile -- another way to put this is that "mutation is freedom" would still let us insert a <code>weak_dereferencable</code> attribute that says that the reference is dereferencable <em>when the function is called</em> (but might be deallocated while the function is running). This we could not do if we want to bless using <code>&amp;UnsafeCell</code> for volatile memory.</p>



<a name="233954597"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/design%20meeting%202021-03-31/near/233954597" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/design.20meeting.202021-03-31.html#233954597">(Apr 10 2021 at 13:17)</a>:</h4>
<p>Okay. I’m still not clear on whether that relates to bubbling or non-bubbling for volatilecell</p>



<a name="233954973"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/design%20meeting%202021-03-31/near/233954973" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/design.20meeting.202021-03-31.html#233954973">(Apr 10 2021 at 13:23)</a>:</h4>
<p>either</p>



<a name="233954996"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/design%20meeting%202021-03-31/near/233954996" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/design.20meeting.202021-03-31.html#233954996">(Apr 10 2021 at 13:23)</a>:</h4>
<p>for a non-bubbling version we could carefully emit e.g. <code>weak_dereferencable(4)</code> for a <code>&amp;(i32, Cell&lt;i32&gt;)</code> since the first 4 bytes are okay with spurious reads</p>



<a name="233954998"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/design%20meeting%202021-03-31/near/233954998" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/design.20meeting.202021-03-31.html#233954998">(Apr 10 2021 at 13:24)</a>:</h4>
<p>the bubbling version would not even allow that</p>



<a name="233958294"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/design%20meeting%202021-03-31/near/233958294" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/design.20meeting.202021-03-31.html#233958294">(Apr 10 2021 at 14:14)</a>:</h4>
<p>So I think my original question is still not addressed</p>



<a name="233958314"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/design%20meeting%202021-03-31/near/233958314" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/design.20meeting.202021-03-31.html#233958314">(Apr 10 2021 at 14:15)</a>:</h4>
<p>When does bubbling vs non-bubbling semantics make a difference for volatilecell?</p>



<a name="233958334"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/design%20meeting%202021-03-31/near/233958334" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/design.20meeting.202021-03-31.html#233958334">(Apr 10 2021 at 14:15)</a>:</h4>
<p>Oh no</p>



<a name="233958346"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/design%20meeting%202021-03-31/near/233958346" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/design.20meeting.202021-03-31.html#233958346">(Apr 10 2021 at 14:15)</a>:</h4>
<p>You did just explain a difference</p>



<a name="233958354"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/design%20meeting%202021-03-31/near/233958354" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/design.20meeting.202021-03-31.html#233958354">(Apr 10 2021 at 14:15)</a>:</h4>
<p>Sorry, I didn’t read carefully enough</p>



<a name="240698931"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/design%20meeting%202021-03-31/near/240698931" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/design.20meeting.202021-03-31.html#240698931">(May 29 2021 at 12:07)</a>:</h4>
<p>I recently learned that while LLVM is moving to make <code>dereferencable</code> mean just "dereferencable when the function is called" (instead of "dereferencable for the duration of this call"), there also is a <code>nofree</code> argument attribute to indicate that the pointee will not be deallocated during the call.<br>
under "mutation is freedom" we could still set <code>nofree</code> for non-interior-mutable shared references. (but not for <code>&amp;mut</code> or <code>&amp;Cell</code>)</p>



<a name="240705983"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/design%20meeting%202021-03-31/near/240705983" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/design.20meeting.202021-03-31.html#240705983">(May 29 2021 at 14:55)</a>:</h4>
<p>couldn't you set nofree except during drop?</p>



<a name="240706520"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/design%20meeting%202021-03-31/near/240706520" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/design.20meeting.202021-03-31.html#240706520">(May 29 2021 at 15:09)</a>:</h4>
<p>if you did that, wouldnt it be unsound if you called a function from drop that did the freeing?</p>



<a name="240706995"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/design%20meeting%202021-03-31/near/240706995" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/design.20meeting.202021-03-31.html#240706995">(May 29 2021 at 15:21)</a>:</h4>
<p><span class="user-mention silent" data-user-id="224471">Lokathor</span> <a href="#narrow/stream/213817-t-lang/topic/design.20meeting.202021-03-31/near/240705983">said</a>:</p>
<blockquote>
<p>couldn't you set nofree except during drop?</p>
</blockquote>
<p>if "any pointer that can mutate a memory can also deallocate it", then <code>&amp;mut</code> memory may be deallocated through that pointer</p>



<a name="240707045"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/design%20meeting%202021-03-31/near/240707045" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/design.20meeting.202021-03-31.html#240707045">(May 29 2021 at 15:22)</a>:</h4>
<p>this is not an aliasing violation -- no other pointer may be used to do that deallocation</p>



<a name="240713589"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/design%20meeting%202021-03-31/near/240713589" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/design.20meeting.202021-03-31.html#240713589">(May 29 2021 at 18:03)</a>:</h4>
<p>Ah, hm, okay. Can you free through &amp;Cell ?</p>



<a name="240713641"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/design%20meeting%202021-03-31/near/240713641" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/design.20meeting.202021-03-31.html#240713641">(May 29 2021 at 18:04)</a>:</h4>
<p>I thought that &amp;Cell was just for Copy types</p>



<a name="240713645"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/design%20meeting%202021-03-31/near/240713645" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/design.20meeting.202021-03-31.html#240713645">(May 29 2021 at 18:04)</a>:</h4>
<p>if we want to <a href="https://github.com/rust-lang/rust/issues/55005#issuecomment-644409424">fix this bug</a> without changing the code, then yes</p>



<a name="240713658"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/design%20meeting%202021-03-31/near/240713658" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/design.20meeting.202021-03-31.html#240713658">(May 29 2021 at 18:04)</a>:</h4>
<p><span class="user-mention silent" data-user-id="224471">Lokathor</span> <a href="#narrow/stream/213817-t-lang/topic/design.20meeting.202021-03-31/near/240713641">said</a>:</p>
<blockquote>
<p>I thought that &amp;Cell was just for Copy types</p>
</blockquote>
<p>no, non-<code>Copy</code> <code>Cell</code> is a thing. it just has no <code>get</code> (but it has <code>replace</code> returning the old value). also I really meant this just as a shorthand for <code>&amp;UnsafeCell</code>, sorry for being sloppy.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>